package com.qj.yantaishan.common.filter;

import com.qj.yantaishan.service.impl.AuthInterceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AuthFilter implements WebMvcConfigurer {
    @Bean
    public AuthInterceptor interceptor(){
        return new AuthInterceptor();
    }
    /**
     * 跨域
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*").allowCredentials(true).allowedMethods("*");
    }

    /**
     * 登录拦截
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        InterceptorRegistration registration = registry.addInterceptor(interceptor());
//        registration.addPathPatterns("/**").excludePathPatterns("/yantaishan/Admin/login","/yantaishan/file/*");
    }
}
